package com.wenrui.springboot.util.common.http;

import com.enzoism.spring.common.http.ResultCode;
import com.enzoism.spring.common.http.Result;

/**
 * 响应结果生成工具
 */
public class ResultGenerator {
    public static Result genSuccessResult() {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(ResultCode.SUCCESS.message())
                .setData(ResultCode.SUCCESS.message());
    }

    public static <T> Result<T> genSuccessResult(T data) {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(ResultCode.SUCCESS.message())
                .setData(data);
    }

    public static Result genFailResult(String message) {
        return new Result()
                .setCode(ResultCode.FAIL)
                .setMessage(message);
    }
}
